package im.xz.cn.xiapvp;

import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;
import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class awa implements Listener {
    @EventHandler
    public void qwq(PrePlayerAttackEntityEvent event) {
        try {
            if (event.getPlayer().hasPermission("xzrui.xiapvp.bypass")) {
            }else {
                try {
                    if (event.getPlayer().getDisplayName().contains("免战") & event.getAttacked().getType().equals(EntityType.PLAYER)) {
                        event.setCancelled(true);
                        event.getPlayer().sendMessage(ChatColor.RED + "你们有人/都处于免战状态");
                    }else {
                    }
                }catch (NullPointerException ignore) {
                }
                try {
                    if (event.getAttacked().getType().equals(EntityType.PLAYER)) {
                        Player player = (Player) event.getAttacked();
                        try {
                            if (player.getDisplayName().contains("免战")) {
                                event.setCancelled(true);
                                event.getPlayer().sendMessage(ChatColor.RED + "你们有人/都处于免战状态");
                            }
                        }catch (NullPointerException ignore) {
                        }
                    }
                }catch (NullPointerException ignore) {
                }
            }
        }catch (NullPointerException ignore) {
        }
    }
}